<template>
  <el-table :data="carTable" style="width: 100%">
    <el-table-column label="车辆照片" prop="chargeCarInfo.avatarImg" #default="scope">
      <el-image style="width: 80px; height: 110px" :src="scope.row.chargeCarInfo.avatarImg" :fit="fit" />
    </el-table-column>
    <el-table-column label="用户昵称" prop="chargeUser.nickName" />
    <el-table-column label="车牌号" prop="carNo" />
    <el-table-column label="汽车品牌" prop="chargeCarInfo.brandName" />
    <el-table-column label="排量" prop="chargeCarInfo.displacement" />
    <el-table-column label="车架号" prop="vehicleIdentifyNo" />
    <el-table-column label="备注" prop="chargeCarInfo.otherDesc" />
    <el-table-column align="right">
      <template #default="scope">
        <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination
      v-model:current-page="carDto.pageNum"
      v-model:page-size="carDto.pageSize"
      :page-sizes="[3, 5, 10, 20]"
      :size="size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
  />
</template>

<script setup>
import {ref} from "vue";
import {CarList} from "@/api/car.js";

const carTable = ref([])
const carDto = ref({
  pageNum: 1,
  pageSize: 10,
})
const total = ref(0)

function getCarList() {
  CarList(carDto.value).then(res =>{
    console.log(res.data)
    if (res.data.code == 200000){
      carTable.value = res.data.data.records
      total.value = res.data.data.total
    }
  })
}
getCarList();

const handleSizeChange = (val) => {
  carDto.value.pageSize= val
  getCarList()
}
const handleCurrentChange = (val) => {
  carDto.value.pageNum = val
  getCarList()
}
</script>


<style scoped>

</style>